package com.tracesystem.controller;


import com.tracesystem.commons.Result;
import com.tracesystem.commons.annotation.RuleValidate;
import com.tracesystem.controller.form.ChangeMemberForm;
import com.tracesystem.controller.form.NewMemberForm;
import com.tracesystem.controller.form.RemMemberForm;
import com.tracesystem.service.IssueProjectRoleRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Kevin Martin
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/issueProjectRoleRel")
@Api(tags = "项目、用户、角色相关操作")
public class IssueProjectRoleRelController {
    @Resource
    private IssueProjectRoleRelService issueProjectRoleRelService;

    /**
     * 移除项目成员
     *
     * @param newMemberForm
     * @return
     */
    @RuleValidate
    @ApiOperation("项目新增成员")
    @PostMapping("newmember")
    public Result<?> newMember(@RequestBody @Validated NewMemberForm newMemberForm) {
        return issueProjectRoleRelService.addMember(newMemberForm);
    }

//    @ApiOperation("移除成员")
//    @PostMapping
//    public Result<?> rmMember(@RequestBody @Validated RemMemberForm remMemberForm) {
//        return issueProjectRoleRelService.cutMember(remMemberForm);
//    }

    /**
     * 修改成员的角色
     *
     * @param changeMemberForm
     * @return
     */
    @RuleValidate
    @ApiOperation("修改成员的角色")
    @PostMapping("changeMember")
    public Result<?> changeMember(@RequestBody @Validated ChangeMemberForm changeMemberForm) {
        return issueProjectRoleRelService.fulshMember(changeMemberForm);
    }

}

